<?php

namespace common\models;

use common\base\BaseBackendActiveRecord;


/**
 * This is the model class for table "user_rebate".
 *
 * @property int $id 自增
 * @property int $uid 用户ID
 * @property int $type 类型 10获得佣金20提现余额扣除
 * @property int $order_id 订单id
 * @property float $money 佣金
 * @property int $date_ym 月份 例：202406
 * @property int $date_ymd  日期 例：20240612
 * @property int $status 状态 10审核中20审核通过-到账中/佣金在途30已到账40审核拒绝50订单已撤销
 * @property float $after_money 操作后金额
 * @property string $request_data 请求
 * @property string $result_data 返回
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 */
class UserRebate extends BaseBackendActiveRecord
{
    //类型 10获得佣金20提现余额扣除
    const   TYPE_GET = 10;
    const   TYPE_DRAW = 20;
    //状态 10审核中20审核通过-到账中30已到账40审核拒绝50订单已撤销
    const    STATUS_AUDIT = 10;
    const    STATUS_PASS = 20;
    const    STATUS_DONE = 30;
    const    STATUS_REFUSE = 40;
    const    STATUS_CANCEL = 50;

    public static function getStatus(){
        return [
            self::STATUS_AUDIT=>'审核中',
            self::STATUS_PASS=>'审核通过-到账中',
            self::STATUS_DONE=>'已到账',
            self::STATUS_REFUSE=>'审核拒绝',
            self::STATUS_CANCEL=>'订单已撤销',
        ];
    }
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'user_rebate';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['created_at','updated_at','request_data', 'result_data'], 'safe'],
            [['uid', 'date_ym','date_ymd','order_id'], 'integer'],
            [['money','after_money'],'number']
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => '自增',
            'uid' => 'uid',
            'order_id'=>'order_id',
            'date_ym' => 'date_ym',
            'date_ymd' => 'date_ymd',
            'money' => 'money',
            'after_money'=>'after_money',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'request_data'=>'请求',
            'result_data'=>'返回'
        ];
    }

    public function getOrder()
    {
        return $this->hasOne(Order::className(), [ 'id' => 'order_id']);
    }
}
